<?php

namespace app\api\controller;

use app\api\model\Article as ArticleModel;
use app\api\model\article\Category as CategoryModel;
use app\api\model\dealer\Withdraw as WithdrawModel;

class Withdraw extends Controller
{

    /* @var \app\api\model\User $user */
    private $user;

    /**
     * 构造方法
     * @throws \app\common\exception\BaseException
     * @throws \think\exception\DbException
     */
    public function _initialize()
    {
        parent::_initialize();
        // 用户信息
        $this->user = $this->getUser();
    }
    /**
     * 服务人员首页
     * @return array
     */
    public function index()
    {
        // 文章分类列表
        $categoryList = CategoryModel::getAll();
        return $this->renderSuccess(compact('categoryList'));
    }

    /*
     * 添加银行卡
     */
    public function bindCardInfo()
    {

        $bank_name = input('bank_name');
        if (empty($bank_name)) $this->renderError('请输入开户行名称');

        $bank_account = input('bank_account');
        if (empty($bank_account)) $this->renderError('请输入银行开户名');

        $bank_card = input('bank_card');
        if (empty($bank_card)) $this->renderError('请输入银行卡号');


        $data = compact('bank_name','bank_account','bank_card');

        $result = \app\api\model\server\User::updateBankInfo($data,$this->user['user_id']);

        return $this->renderSuccess(compact('result'));

    }

    /*
     * 获取银行卡信息
     */

    public function getBankInfo()
    {
        $result = \app\common\model\server\User::bankInfo($this->user['user_id']);

        return $this->renderSuccess(compact('result'));
    }

}